package main

import (
	"fmt"
	"time"
)

func running()  {
	var times int
	for {
		times++
		fmt.Println("tip", times)
		time.Sleep(time.Second)
	}
}

//非线程安全的计数器，共享内存变量有相互竞争关系
func main() {
	//go running()
	//var input string
	//fmt.Scanln(&input)
	counter := 0
	for i := 0; i < 5000; i++ {
		go func () {
			counter++
		} ()
	}
	//等待1秒
	time.Sleep(time.Second)
	fmt.Printf("counter=%d", counter)
}
